<template>
    <div class="app-container order_list">
        <transition name="el-zoom-in-top">
            <div class="status_main" v-show="showStatus">
                <div :class="{ 'active': index === currentIndex }" class="status_item" v-for="(item, index) in order_status"
                    :key="item.id" @click="itemClick(item, index)">
                    <span>{{ item.label }} </span>(
                    <span class="num">{{ item.num }}</span>)
                </div>
            </div>
        </transition>
        <el-card class="box-card" shadow="never" v-show="showSearch">
            <template #header>
                <div class="p20">
                    <i class="el-icon-search mr10"></i>
                    <span>筛选结果</span>
                    <div class="button-main">
                        <!-- <div class="button_item">查询结果</div> -->
                        <div class="button_item" @click="showSearchForm">高级搜索</div>
                    </div>
                    <div class="hide_status" @click="showStatus = !showStatus">
                        <i class="el-icon-arrow-down" v-if="!showStatus"></i>
                        <i class="el-icon-arrow-up" v-if="showStatus"></i>
                        <span>{{ showStatus ? '收起筛选' : '打开筛选' }}</span>
                    </div>
                </div>
            </template>
            <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
                <el-form-item label="输入搜索" prop="orderNo">
                    <el-input v-model="queryParams.orderNo" placeholder="订单编号/商品货号" clearable @keyup.enter="handleQuery" />
                </el-form-item>
                <el-form-item label="收货人" prop="consignee">
                    <el-input v-model="queryParams.consignee" placeholder="收货人姓名/手机号" clearable
                        @keyup.enter="handleQuery" />
                </el-form-item>
                <el-form-item label="下单时间">
                    <el-date-picker v-model="dateRange" style="width: 100%" value-format="YYYY-MM-DD" type="daterange"
                        range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" format="YYYY-MM-DD"
                        @change="handleQuery" placeholder="选择下单时间"></el-date-picker>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="handleQuery">搜索</el-button>
                    <el-button @click="resetQuery">重置</el-button>
                </el-form-item>
            </el-form>
        </el-card>

        <el-card shadow="never" :body-style="{ padding: '20px' }">
            <template #header>
                <div class="p20">
                    <i class="el-icon-s-grid mr10"></i>
                    <span>数据列表</span>
                    <div class="button-main">

                        <!-- <Nickname v-if="show" id="doudian-nickname" ref="nickname" :data="entryData"></Nickname> -->
                        <!-- <el-button type="primary" @click="next">下一个</el-button> -->
                        <el-button type="primary" @click="batchPrint">批量打印</el-button>
                        <el-button type="primary" @click="clearPrintCache">清空打印缓存</el-button>
                        <el-button type="primary" @click="handleDownload">下载配货单</el-button>
                        <el-button type="primary" @click="printShippingOrder">打印发货单</el-button>
                        <el-button type="primary" @click="printDeliver">打印快递单</el-button>
                        <el-button type="primary" @click="handleDeliver">批量发货</el-button>
                        <el-button type="primary" @click="handleView">导出订单</el-button>
                    </div>
                </div>
            </template>

            <el-table style="height: calc(100vh - 480px);" border scrollbar-always-on v-loading="loading" :data="dataSource"
                @selection-change="handleSelectionChange">
                <el-table-column type="selection" width="55" align="center" :selectable="selectHandle" />
                <el-table-column label="#" type="index" align="center" width="100"> </el-table-column>
                <el-table-column label="订单编号" align="center" prop="orderNo" width="190">
                    <template #default="scope">
                        <a style="color:#409eff;cursor: pointer;" @click="handleDetail(scope.row)">{{ scope.row.orderNo
                        }}</a>
                    </template>
                </el-table-column>
                <el-table-column label="店铺名称" align="center" prop="storeName" width="180" />
                <el-table-column label="下单时间" align="center" prop="addTime" width="180" sortable />
                <el-table-column label="买家昵称" align="center" prop="nickName" width="180" sortable>
                    <template #default="scope">
                        <div v-if="scope.row.nickName">{{ scope.row.nickName }}</div>
                        <div v-else>
                            <img class="nickname-img" v-if="scope.row.rsrvStr9" :src="scope.row.rsrvStr9" />
                            <!-- <Nickname v-else  :data="entryData"></Nickname> -->
                        </div>
                    </template>
                </el-table-column>

                <el-table-column label="收货人/买家" align="center" prop="postReceiver" width="120">
                    <template #default="scope">
                        <div>{{ scope.row.postReceiver }}</div>
                        <!-- /{{ scope.row.userNickName }} -->
                    </template>
                </el-table-column>
                <el-table-column label="联系电话" align="center" prop="postTel" width="120" />
                <el-table-column label="收货地址" align="center" prop="detail" width="240">
                    <template #default="scope">
                        <div>{{ scope.row.province }}{{ scope.row.city }}{{ scope.row.area }}{{ scope.row.detail }}</div>
                    </template>
                </el-table-column>
                <el-table-column label="订单金额" align="center" prop="allTotalAmount" />

                <el-table-column label="支付时间" align="center" prop="createTime" width="180" />
                <el-table-column label="单序" align="center" prop="serialNumber" />
                <el-table-column label="订单来源" align="center" width="120">
                    <template #default="scope">
                        {{ selectDictLabel(order_source, scope.row.orderSource) }}
                    </template>
                </el-table-column>
                <el-table-column label="配送单号" align="center" prop="peisongNo" width="180" />
                <el-table-column label="状态" align="center" prop="orderState">
                    <template #default="scope">
                        {{ selectDictLabel(order_status, scope.row.orderState) }}
                    </template>
                </el-table-column>
                <el-table-column label="操作" align="center" width="200" fixed="right">
                    <template #default="scope">
                        <text type="text" style="color:#409eff;cursor: pointer;" @click="handleDetail(scope.row)">查看</text>
                        <el-divider direction="vertical"></el-divider>
                        <text type="text" v-if="showReturn(scope.row) && scope.row.orderState == 3"
                            style="color:#409eff;cursor: pointer;" @click="handleReturn(scope.row)">回访</text>
                        <el-divider direction="vertical"
                            v-if="showReturn(scope.row) && scope.row.orderState == 3"></el-divider>
                        <text type="text" style="color:#409eff;cursor: pointer;" @click="outBoxPrintFn(scope.row)">打印</text>
                        <el-divider direction="vertical"></el-divider>
                        <text v-hasPermi="['system:messagePackagePurchaseHistory:add', 'system:messageTemplate:list']"
                            type="text" style="color:#409eff;cursor: pointer;" @click="showSendMessage(scope.row)">提醒</text>
                    </template>
                </el-table-column>
            </el-table>
            <pagination v-show="total > 0" :total="total" v-model:page.sync="queryParams.pageNum"
                v-model:limit.sync="queryParams.pageSize" @pagination="getList" />
        </el-card>
        <addForm ref="modelForm" @ok="getList"></addForm>
        <printDeliverForm ref="printDeliverForm"></printDeliverForm>
        <printShipping ref="printShipping"></printShipping>
        <downloadAllocation ref="downloadAllocation"></downloadAllocation>
        <batchDeliverForm ref="batchDeliverForm"></batchDeliverForm>
        <searchForm ref="searchForm" :query="queryParams" :status="order_status" :source="order_source" @search="search">
        </searchForm>
        <returnForm ref="returnForm"></returnForm>
        <sendMessageForm ref="sendMessageForm"></sendMessageForm>
    </div>
</template>

<script>
import addForm from './modules/addForm.vue';
// 发送短信
import sendMessageForm from './modules/sendMessageForm.vue';
// 打印快递单
import printDeliverForm from './modules/printDeliverForm.vue';
// 回访
import returnForm from '../ordersReturn/modules/addForm.vue';
// 打印发货单
import printShipping from './modules/printShipping.vue';
// 下载配货单
import downloadAllocation from './modules/downloadAllocation.vue';
// 批量发货
import batchDeliverForm from './modules/batchDeliverForm.vue';
// 高级搜索
import searchForm from './modules/searchForm.vue';
import listMixin from '@/mixins/listMixin';
import { getOrderStateList } from '@/api/goods/order/index';
import { getDicts } from '@/api/system/dict/data/index';
import { Nickname } from '@/utils/guard/@open-fxg/bodyguard-vue'
// hiprint
import { autoConnect, disAutoConnect, hiprint, defaultElementTypeProvider } from 'vue-plugin-hiprint'
import request from '@/utils/request';
import { getPrintList, updatePrintStatus, getOrdersAccessToken } from '@/api/goods/order/index';
import { findDefaultByType } from '@/api/goods/express/index'
import Cookie from 'js-cookie'
import { randomUUID } from '@/utils/util'
import order from '@/api/goods/order/index';
import useUserStore from '@/store/modules/user'
import axios from 'axios'
const userStore = useUserStore()
export default {
    name: "orders",
    components: {
        addForm, printDeliverForm, printShipping, downloadAllocation, batchDeliverForm,
        searchForm, returnForm, sendMessageForm, Nickname
    },
    mixins: [listMixin],
    dicts: ["order_status", "order_source"],
    data() {
        return {
            queryParams: {
                orderNo: '',
                pageNum: 1,
                pageSize: 20,
                peisongNo: ''
            },
            showStatus: true,
            currentIndex: 0,
            order_status: [],
            order_source: [],
            stateObj: {},
            dateRange: [],
            templateList: [],
            pageKey: randomUUID(),
            printList: [],
            messageTip: false,
            printing: false,
            connected: false,
            defaultTemplateContent: '',
            defaultReturnTemplateContent: '',
            timmer: null,
            printNum: 1,
            tokenData: {},
            entryData: {
                orderId: '',
                token: '',
            },
            urls: {
                list: '/order/orders/list',
                delete: '/order/orders',
                printTemplate: '/order/template/list',
            },
            n: 0,
            show: false,
        };
    },
    watch: {
        stateObj(newValue, oldValue) {
            if (this.order_status.length) {
                this.parseStatus()
            }
        },
        '$route': {
            handler: (to, from) => {
                // 路由发生变化时的处理逻辑

                console.log('销毁 :>> ');
                disAutoConnect()
                clearInterval(this.timmer)
            },
            // 设置为深度监听
            deep: true
        }
    },
    created() {
        // this.getOrdersAccessTokenByStore()
    },
    async mounted() {
        // setTimeout(() => {
        //     this.getPrintList();
        // }, 3000);
        window.addEventListener('beforeunload', (event) => {
            // 监听页面离开前事件,页面刷新，pageKey一致就清空
            const timerCookie = Cookie.get('timer') ? JSON.parse(Cookie.get('timer')) : null
            if (timerCookie && timerCookie.pageKey === this.pageKey) {
                Cookie.remove('timer')
                console.log('离开 :>> ', timerCookie);
            }
        });
        try {

            setTimeout(() => {
                this.getDicts(['order_source']);
                this.getStatus();
            }, 1000)
            // 获取默认模板
            await this.getDefaultTemplate('2', 'defaultTemplateContent');
            await this.getDefaultTemplate('3', 'defaultReturnTemplateContent');
            await this.getOrderSetting();

            const timerCookie = Cookie.get('timer') ? JSON.parse(Cookie.get('timer')) : null
            console.log('this.pageKey :>> ', this.pageKey);
            console.log('timerCookie :>> ', timerCookie);
            if ((!timerCookie || (timerCookie.pageKey === this.pageKey))) {
                Cookie.set('timer', JSON.stringify({ pageKey: this.pageKey }))
                this.init();
                // 自动打印
                this.printMain()
                // setTimeout(() => {
                //     this.batchPrint()
                // }, 2000)
            }

            if (this.$route.path !== '/order/order') {
                console.log('关闭了 :>> ');
                disAutoConnect()
                clearInterval(this.timmer)
            }

        } catch (e) {
            console.log('e :>> ', e);
        }
    },
    beforeDestroy() {
        console.log('销毁 :>> ');
        throw new Error('销毁')
        clearInterval(this.timmer)
    },
    methods: {
        // 解密
        next(orderId) {
            return new Promise((resolve, reject) => {
                this.show = false
                this.n++
                this.entryData.orderId = this.dataSource[this.n].orderNo//orderId
                this.$forceUpdate()
                setTimeout(() => {
                    this.show = true
                    this.$nextTick(() => {
                        this.$refs.nickname.renderNicename(() => {
                            console.log('渲染完毕');
                            // 渲染完毕
                            const shadowRoot = document.querySelector('#doudian-nickname').shadowRoot;
                            setTimeout(() => {
                                const dom = shadowRoot.querySelector('.ecom-open-bodyguard-eye');
                                // dom && dom.click();
                                // setTimeout(() => {
                                //     const img = shadowRoot.querySelector('img');
                                //     if (img && img.src) {
                                //         resolve(img.src)
                                //     } else {
                                //         // this.next(orderId)
                                //     }
                                // }, 1000)
                                resolve()
                            }, 1000)
                        })

                    })
                }, 1000)
            })
        },

        /**
         * 解密
         * @param {*} orderId 订单id
         */
        decode(order) {
            return new Promise(async (resolve, reject) => {
                this.show = false;
                this.entryData.orderId = order.orderNo;
                if (!this.tokenData[`token${order.storeId}`]) {
                    await this.getToken(order.storeId);
                } else {
                    this.entryData.token = this.tokenData[`token${order.storeId}`];
                }
                await new Promise((resolve) => setTimeout(resolve, 3000));
                this.show = true;
                this.$forceUpdate();
                await this.$nextTick();
                await new Promise((resolve) => this.$refs.nickname.renderNicename(resolve));
                await new Promise((resolve) => setTimeout(resolve, 1000));
                const shadowRoot = document.querySelector('#doudian-nickname').shadowRoot;
                console.log('shadowRoot :>> ', shadowRoot);
                await new Promise((resolve) => setTimeout(resolve, 1000));
                const dom = shadowRoot.querySelector('.ecom-open-bodyguard-eye');
                console.log('dom :>> ', dom);
                if (dom) {
                    dom.click();
                } else {
                    // reject('解密失败');
                }
                await new Promise((resolve) => setTimeout(resolve, 1000));
                const img = shadowRoot.querySelector('img');
                if (img && img.src) {
                    this.errorMsg = '解密成功';
                    let parasm = [{
                        orderNo: order.orderNo,
                        nickName: img.src
                    }]
                    await this.updateNickname(parasm);
                    resolve(img.src);
                } else {
                    // location.reload()
                    reject('解密失败');
                }
            })
        },
        /**
 * 获取店铺解密token
 * @param {string | number} storeId 店铺id
 */
        getToken(storeId) {
            return new Promise((resolve, reject) => {
                request({
                    url: '/order/doudian/getAccessToken/' + storeId,
                    method: 'get'
                }).then(res => {
                    console.log('res :>> ', res);
                    let json = JSON.parse(res.originResponse)
                    if (res.success) {
                        this.errorMsg = ''
                        this.tokenData[`token${storeId}`] = json.data.token
                        this.entryData.token = json.data.token
                        console.log('this.entryData :>> ', this.entryData);
                        resolve(json.data)
                    } else {
                        this.errorMsg = json.msg
                        // location.reload()
                        reject(res)
                    }
                }).catch(err => {
                    reject(err)
                })
            })
        },
        // 获取订单列表
        getOrderList() {
            return new Promise((resolve, reject) => {
                request({
                    url: '/order/orders/getNotNickNamePageList?pageSize=1&pageNum=1',
                    method: 'get'
                }).then(async res => {
                    if (res.code == 200) {
                        this.orderList = res.rows
                        if (!this.orderList.length) {
                            this.errorMsg = '没有订单, 1秒延时'
                            await new Promise((resolve) => setTimeout(resolve, 1000));
                        }
                        resolve()
                    } else {
                        this.errorMsg = res.msg
                        // location.reload()
                        reject(res)
                    }
                })
            })
        },
        // 修改昵称到订单
        updateNickname(params) {
            return new Promise((resolve, reject) => {
                request({
                    url: '/order/orders/batchUpdateNickNameImage',
                    method: 'post',
                    data: params
                }).then(res => {
                    if (res.code == 200) {
                        this.errorMsg = '修改成功'
                        resolve()
                    } else {
                        this.errorMsg = res.msg
                        reject(res)
                    }
                })
            })
        },
        handleDetail(row) {
            // this.$router.push({
            //     path:`/order/order_detail`,
            //     params:{
            //         id:id
            //     }
            // })
            window.open(`/order/order_detail?id=${row.id}`, '_blank');
        },
        itemClick(item, index) {
            this.currentIndex = index;
            this.queryParams.orderState = +item.value || '';
            this.getList();
        },
        printDeliver(id) {
            this.$refs.printDeliverForm.show(id);
        },
        printShippingOrder() {
            this.$refs.printShipping.show();
        },
        handleDownload() {
            this.$refs.downloadAllocation.show();
        },
        handleDeliver() {
            this.$refs.batchDeliverForm.show();
        },
        showSearchForm() {
            this.$refs.searchForm.show(this.queryParams, this.dateRange);
        },
        search(data, dateRange) {
            console.log('data :>> ', data);
            this.queryParams = data;
            this.currentIndex = this.order_status.findIndex(v => v.value == this.queryParams.orderState);
            this.currentIndex = this.currentIndex == -1 ? 0 : this.currentIndex;
            this.queryParams.orderState = +this.queryParams.orderState || '';
            this.dateRange = dateRange;
            this.getList();
        },

        getQueryParams() {
            let params = Object.assign({}, this.queryParams);
            params.params = { ...this.params };
            if (this.dateRange && this.dateRange.length) {
                params.params['createBeginTime'] = this.dateRange[0] + ' 00:00:00';
                params.params['createEndTime'] = this.dateRange[1] + ' 23:59:59';
            }
            return params;
        },
        // 获取不同订单状态的订单数量
        getOrderStateList() {
            getOrderStateList().then(res => {
                this.stateObj = res.data;
            });
        },
        getStatus() {
            Promise.all([getOrderStateList(), getDicts('order_status')]).then(res => {
                this.stateObj = res[0].data;
                this.order_status = res[1].data.map(v => {
                    return {
                        label: v.dictLabel.replace(/\s*（.*?）/g, ''),
                        value: v.dictValue,
                        num: 0
                    }
                });
                this.parseStatus()
            })
        },
        parseStatus() {
            this.order_status = this.order_status.map(v => {
                switch (v.value) {
                    case '0':
                        v.num = this.stateObj.allStateNumber
                        break;
                    case '1':
                        v.num = this.stateObj.obligationNumber
                        break;
                    case '2':
                        v.num = this.stateObj.waitSendNumber
                        break;
                    case '3':
                        v.num = this.stateObj.shippedNumber
                        break;
                    case '4':
                        v.num = this.stateObj.completedNumber
                        break;
                    case '5':
                        v.num = this.stateObj.closedNumber
                        break;
                    case '6':
                        v.num = this.stateObj.paidNumber
                        break;
                    case '7':
                        v.num = this.stateObj.partialDeliveryNumber
                        break;
                    default:
                        break;
                }
                return v
            });
        },
        // hiprint初始化
        init() {
            // 初始化
            hiprint.init({
                providers: [new defaultElementTypeProvider()],
                host: 'http://localhost:17521', // 可在此处设置连接地址与端口号
                token: '', // 可在此处设置连接 token 可缺省
            })
            // 调整配置
            hiprint.setConfig({
                showSizeBox: false,
            })
            autoConnect()
        },
        async printMain() {
            const timerCookie = Cookie.get('timer') ? JSON.parse(Cookie.get('timer')) : null
            console.log('this.pageKey :>> ', this.pageKey);
            console.log('timerCookie :>> ', timerCookie);
            if ((!timerCookie || (timerCookie.pageKey === this.pageKey))) {
                console.log('777 :>> ', 777);

                await new Promise((resolve) => setTimeout(resolve, 2000));
                Cookie.set('timer', JSON.stringify({ pageKey: this.pageKey }))
                if (window.hiwebSocket.opened) {
                    if (this.messageTip) {
                        this.$modal.msgSuccess('连接成功，开始打印')
                        this.messageTip = false
                    }

                    console.log('666 :>> ', 666);
                    await this.getPrintList();
                    await this.batchPrint()
                } else {
                    if (!this.messageTip) {
                        this.$modal.msgError('打印服务未连接，请检查打印服务是否开启')
                        this.messageTip = true
                    }
                    // this.$modal.msgError('打印服务未连接，请检查打印服务是否开启')
                }
            } else {
                // 延迟两秒
                console.log('延迟两秒 :>> 页面key不一致，请刷新缓存');
                await new Promise((resolve) => setTimeout(resolve, 2000));
            }
            this.printMain()
        },
        // 打印
        async outBoxPrintFn(row) {
            let defaultTemplate = this.defaultTemplateContent
            if (['21', '22', '39'].includes(row.orderState)) {
                defaultTemplate = this.defaultReturnTemplateContent || this.defaultTemplateContent
            }
            let detail = await this.getOrderDetail(row)
            // if (!detail.rsrvStr9 && !detail.nickName) {
            // detail.rsrvStr9 = await this.decode(detail)
            // }
            let hiprintTemplate = new hiprint.PrintTemplate({
                template: JSON.parse(defaultTemplate)
            })
            hiprintTemplate.on('printSuccess', data => {
                console.log('打印完成，修改状态...')

            })
            hiprintTemplate.on('printError', data => {
                console.log('data :>> ', data);
                console.log('打印失败')
            })

            hiprintTemplate.print(detail)

        },
        /**
         * @自动打印
         */
        async autoPrint() {
            let defaultTemplate = this.defaultTemplateContent
            if (this.printList.length && ['21', '22', '39'].includes(this.printList[0].orderState)) {
                defaultTemplate = this.defaultReturnTemplateContent
            }
            let hiprintTemplate = new hiprint.PrintTemplate({
                template: JSON.parse(defaultTemplate)
            })

            hiprintTemplate.on('printSuccess', async (data) => {
                console.log('打印完成，修改状态...')
                if (process.env.NODE_ENV === 'development') {
                    await this.updatePrintStatus(this.printList[0].id)
                }
                this.printing = false
            })
            hiprintTemplate.on('printError', data => {
                console.log('data :>> ', data);
                console.log('打印失败')
            })
            for (let index = 0; index < this.printList.length; index++) {//this.printList.length
                this.printing = true
                let detail = this.printList[index];
                for (var i = 0; i < this.printNum; i++) {
                    hiprintTemplate.print2(detail)
                }

            }

        },
        async batchPrint() {
            return new Promise((resolve, reject) => {
                const setTemplate = (type) => {
                    if (['21', '22', '39'].includes(type)) {
                        return this.defaultReturnTemplateContent
                    }
                    return this.defaultTemplateContent
                }
                const initTemplate = (type) => {
                    return new hiprint.PrintTemplate({
                        template: JSON.parse(setTemplate(type))
                    })
                }


                for (let index = 0; index < this.printList.length; index++) {
                    let detail = this.printList[index];
                    let hiprintTemplate = initTemplate(detail.orderState)
                    hiprintTemplate.print2(detail)
                    this.updatePrintStatus(detail.id)
                }
                resolve()
            })
        },
        // 发送短信
        showSendMessage(row) {
            this.$refs.sendMessageForm.show(row);
        },
        updatePrintStatus(ids) {
            // 更新打印状态
            return new Promise((resolve, reject) => {
                updatePrintStatus(ids).then(res => {
                    console.log('状态修改成功 :>> ');
                    resolve()
                })
            })
        },

        // 获取待打印列表
        getPrintList() {
            return new Promise((resolve, reject) => {
                getPrintList({ authorName: userStore.nickname, pageSize: 20, pageNum: 1 }).then(res => {
                    this.printList = res;
                    resolve()
                })
            })
        },
        getDefaultTemplate(type, key) {
            // 1:快递单 2:发货单 3:退货单
            return new Promise((resolve, reject) => {
                findDefaultByType(type).then(res => {
                    this[key] = res.data && res.data.templateContent || null
                    resolve()
                })
            })
        },
        resetQuery() {
            this.queryParams = {
                orderNo: '',
                pageNum: 1,
                pageSize: 20
            }
            this.dateRange = []
            this.getList()
        },

        getOrderDetail(row) {
            return new Promise((resolve, reject) => {
                order.get(row.id).then(res => {
                    resolve(res.data)
                });
            })
        },
        handleReturn(row) {
            this.$refs.returnForm.add(row);
        },
        showReturn(row) {
            let now = new Date().getTime();
            let shipTime = new Date(row.shipTime).getTime();
            if (now - shipTime > 1000 * 60 * 60 * 24 * row.warningDay) {
                return true;
            } else {
                return false;
            }
        },
        // 获取订单设置
        getOrderSetting() {
            return new Promise((resolve, reject) => {
                order.getOrdersSetting().then(res => {
                    if (res.code === 200) {
                        this.printNum = res.rows.length ? res.rows[0].printNum : 1
                    }
                    resolve(res.data)
                });
            })
        },
        clearPrintCache() {
            Cookie.remove('timer')
            location.reload()
        },
        getOrdersAccessTokenByStore() {
            getOrdersAccessToken('173307853')
            //     .then(res => {
            //     console.log('res :>> ', res);
            //     // this.entryData.token = JSON.parse(res.originResponse).data.token
            //     // console.log('this.entryData :>> ', this.entryData);
            // });
        }
    },
};
</script>
<style type="text/css" lang="scss" scoped>
.app-container {
    background-color: #F9F9F9;
    color: #666;
    min-height: calc(100vh - 84px);
}

.box-card {
    margin-bottom: 20px;
}

.status_main {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 10px;
}

.status_item {
    padding: 8px 16px;
    cursor: pointer;
    border: 1px solid #E4E4E4;
    margin-right: 10px;
    color: #666;
    background-color: #fff;
    font-size: 14px;
}

.status_item.active {
    background-color: #409eff;
    color: #fff;
}

.num {
    color: #f56c6c;
}

.active .num {
    color: #fff;
}

.button-main {
    float: right;
    margin-top: -10px;
}

.button_item:not(:last-child) {
    border-right: none;
}

.button_item {
    padding: 8px 16px;
    cursor: pointer;
    border: 1px solid #E4E4E4;
    color: #409eff;
    background-color: #fff;
    display: inline-block;
}

.button_item:hover {
    background-color: #409eff;
    color: #fff;
    cursor: pointer;
}

.p20 {
    padding: 6px 0;
}

.hide_status {
    float: right;
    margin-right: 10px;
    color: #409eff;
    cursor: pointer;

    i {
        margin-right: 4px;
        color: #409eff;
    }
}

.nickname-img {
    max-width: 150px;
}
</style>

<style type="text/css">
.order_list .el-card__header {
    background-color: #f5f7fa;
}
</style>
